package org.gdpu.service.impl;

import org.gdpu.base.DaoSupport;
import org.gdpu.model.*;
import org.gdpu.service.TestPaperInfoService;
import org.gdpu.service.TestPaperService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-6-5
 * Time: 下午9:05
 * To change this template use File | Settings | File Templates.
 */
@Service
@Transactional
public class TestPaperServiceImpl extends DaoSupport<TestPaper> implements TestPaperService {

    @Override
    public List<Test> findTestByCategory(TestCategory category,Subject subject) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("category", category);
        params.put("subject", subject);
        List<Test> tests = (List<Test>) this.findByFields(Test.class, params);
        return tests.size() > 0 ? tests : null;
    }

    @Override
    public List<TestPaperInfo> findAllTest() {
        Map<String, Object> params = new HashMap<String, Object>();
        List<TestPaperInfo> tests = (List<TestPaperInfo>) this.findByFields(TestPaperInfo.class, params);
        return tests.size() > 0 ? tests : null;
    }
}
